package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StrategyCatalogQuery;
import cn.wolfcode.trip.base.service.IRegionService;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.util.JSONResult;
import cn.wolfcode.trip.base.util.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("strategyCatalog")
public class StrategyCatalogController {
    @Autowired
    IStrategyCatalogService strategyCatalogService;
    @Autowired
    IStrategyService strategyService;

    @RequestMapping("list")
    public String list(@ModelAttribute("qo") StrategyCatalogQuery qo, Model model){
        model.addAttribute("pageInfo",strategyCatalogService.query(qo));
        model.addAttribute("strategies",strategyService.listAll());

        return "strategy/catalog";
    }
    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyCatalog entity) {
        strategyCatalogService.saveOrUpdate(entity);
        return new JSONResult(); //象征性返回操作成功
    }
    @RequestMapping("listByStrategyId")
    @ResponseBody
    public Object listByStrategyId(Long strategyId) {
        return strategyCatalogService.listByStrategyId(strategyId);
    }
}
